/*******************************************************************
 * author   :  Charlies-ls
 * Date     :  2021-09-26
 * Copyright (c) 2021. artestplay@outlook.com. All Rights Reserved.
 *******************************************************************/

#include "ax_time.h"
#include <sys/time.h>

/**
 * @brief get timestamp, ms, from 1970s
 * @return
 */
long ax_timestamp()
{
    struct timeval tv;
    gettimeofday(&tv, NULL);
    return  tv.tv_sec * 1000 + tv.tv_usec / 1000;
}


struct timeval ax_timeval_from_ms(int ms)
{
    struct timeval tv;
    tv.tv_sec = ms / 1000;
    tv.tv_usec = ms % 1000 * 1000;
    return tv;
}
